Holds a Buffer and make it easy to cast the binary data. More...
Public Member Functions | |
BufferCast ()=default | |
BufferCast (unsigned long long size) | |
BufferCast (T *data, unsigned long long size) | |
BufferCast (const Buffer &buffer) | |
BufferCast (Buffer &&buffer) | |
BufferCast (const BufferCast &cast) | |
BufferCast (BufferCast &&cast) | |
~BufferCast ()=default | |
T * | getData () const |
unsigned long long | getSize () const |
bool | empty () const |
T & | front () |
const T & | front () const |
T & | back () |
const T & | back () const |
void | clear () |
void | resize (unsigned long long size) |
T & | append (const T &value) |
Buffer | relinquishBufferOwnership () |
BufferDataDescriptor | relinquishDataOwnership () |
T & | operator[] (unsigned long long index) |
const T & | operator[] (unsigned long long index) const |
template<std::size_t S> | |
BufferCast (const std::array< T, S > &array) | |
template<typename U , std::size_t S> | |
BufferCast (const std::array< U, S > &array) | |
BufferCast (const std::vector< T > &vec) | |
template<typename U > | |
BufferCast (const std::vector< U > &vec) | |
Holds a Buffer and make it easy to cast the binary data.
This class holds a binary Buffer and abstracts all casting needed when using a buffer to keep data that can be interpreted. This buffer cast owns the buffer, meaning that it also owns the memory allocated.
If you need a simple non-owning view over the data, consider looking at BufferView.
|
default |
Default constructor. The buffer will be empty.
nkMemory::BufferCast< T >::BufferCast | ( | unsigned long long | size | ) |
Size constructor. Will allocate the size requested within the buffer. Memory will be 0-cleared.
size | The size of the buffer to create, in number of elements. |
nkMemory::BufferCast< T >::BufferCast | ( | T * | data, |
unsigned long long | size | ||
) |
Data constructor. Will copy the data into its internal memory.
data | Pointer to the data to copy. |
size | The size of the data to copy, in number of elements. |
nkMemory::BufferCast< T >::BufferCast | ( | const Buffer & | buffer | ) |
Copy buffer constructor. Will duplicate the data.
buffer | The buffer to copy. |
nkMemory::BufferCast< T >::BufferCast | ( | Buffer && | buffer | ) |
Move buffer constructor. Data will be moved into the buffer being constructed.
buffer | The buffer to move. |
nkMemory::BufferCast< T >::BufferCast | ( | const BufferCast< T > & | cast | ) |
Copy cast constructor. Will duplicate the data.
cast | The cast to copy. |
nkMemory::BufferCast< T >::BufferCast | ( | BufferCast< T > && | cast | ) |
Move cast constructor. Data will be moved into the cast being constructed.
cast | The cast to move. |
|
default |
Destructor. The destructor frees the memory, invalidating all potential pointers to it.
nkMemory::BufferCast< T >::BufferCast | ( | const std::array< T, S > & | array | ) |
Utility copy constructor with arrays.
array | The array to copy from. |
nkMemory::BufferCast< T >::BufferCast | ( | const std::array< U, S > & | array | ) |
Utility copy constructor with arrays, which memory will be reinterpreted to another type.
array | The array to copy from. |
nkMemory::BufferCast< T >::BufferCast | ( | const std::vector< T > & | vec | ) |
Utility copy constructor with vectors.
vec | The vector to copy from. |
nkMemory::BufferCast< T >::BufferCast | ( | const std::vector< U > & | vec | ) |
Utility copy constructor with vectors, which memory will be reinterpreted to another type.
vec | The vector to copy from. |
T* nkMemory::BufferCast< T >::getData | ( | ) | const |
unsigned long long nkMemory::BufferCast< T >::getSize | ( | ) | const |
bool nkMemory::BufferCast< T >::empty | ( | ) | const |
T& nkMemory::BufferCast< T >::front | ( | ) |
const T& nkMemory::BufferCast< T >::front | ( | ) | const |
T& nkMemory::BufferCast< T >::back | ( | ) |
const T& nkMemory::BufferCast< T >::back | ( | ) | const |
void nkMemory::BufferCast< T >::clear | ( | ) |
Clears the buffer, freeing its internal memory and resetting it to its empty state.
void nkMemory::BufferCast< T >::resize | ( | unsigned long long | size | ) |
Resizes the buffer for it to fit a given size. This will trigger a reallocation of the data. In the process, the buffer will copy its content to the new memory area.
size | The size to fit, in number of elements. |
T& nkMemory::BufferCast< T >::append | ( | const T & | value | ) |
Appends an element to the buffer. This will cause the buffer to reallocate and copy data around. Use it wisely.
value | The value to append. |
Buffer nkMemory::BufferCast< T >::relinquishBufferOwnership | ( | ) |
Forward the internal buffer's ownership and memory.
BufferDataDescriptor nkMemory::BufferCast< T >::relinquishDataOwnership | ( | ) |
Forward the internal buffer's data ownership and memory.
T& nkMemory::BufferCast< T >::operator[] | ( | unsigned long long | index | ) |
Indexing operator.
index | The index of the element to index in the memory. |
const T& nkMemory::BufferCast< T >::operator[] | ( | unsigned long long | index | ) | const |
Indexing operator, const versioned.
index | The index of the element to index in the memory. |